import QtQuick 2.6
import Toou2D 1.0

TPopup{
    id:popup
    signal topage(string uri,string title);
    property int  width;
    property int  height;
    property bool isopen: false;

    onOpened: isopen = true;
    onHided:  isopen = false;

    onTriggeredBackground: hide(true);
    backgroundComponent: null;

    TRectangle{
        id:bg
        width: popup.width;
        height: popup.height;
        x:isopen ? 0 : -width;
        theme.groupName: "menubg"
        color:"#3D3D3D"

        Column{
            spacing: 10;
            anchors.horizontalCenter: parent.horizontalCenter;

            Item{
                width: popup.width;
                height: 40;
                Image {
                    anchors.centerIn: parent;
                    width: popup.width;
                    height: 40;
                    id: logo;
                    source: "images/conch.png";
                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            topage("qrc:/Home.qml","Home");
                            hide(true);
                        }
                    }

                }

            }


            TDividerLine{
                width: popup.width * 0.9
                height: 1;
                color: "#464646"
            }

            Repeater{

                model: [
                    {label:"标注工具",icon:TAwesomeType.FA_arrows,uri:"qrc:/labelTool.qml"},
                    {label:"采集工具",icon:TAwesomeType.FA_contao,uri:"qrc:/collectTool.qml"},
//                    {label:"Home",icon:TAwesomeType.FA_home,uri:"qrc:/Home.qml"},
//                    {label:"Control",icon:TAwesomeType.FA_rocket,uri:"qrc:/Control.qml"},
//                    {label:"Awesome",icon:TAwesomeType.FA_font_awesome,uri:"qrc:/Awesome.qml"},
                    {label:"退出",icon:TAwesomeType.FA_close,uri:"qrc:/Awesome.qml"},
                ]

                delegate: TIconButton{
                    width: parent.width;
                    spacing: 15
                    height: 40;
                    contentHAlign: Qt.AlignLeft
                    label.text: modelData.label;
                    label.color: "#FCFCFC"

                    icon.source: modelData.icon;
                    icon.color: "#FCFCFC"
                    backgroundComponent: null;
                    onClicked: {
                        topage(modelData.uri,modelData.label);
                        hide(true);
                    }
                }
            }
        }

        TLabel{
            anchors.horizontalCenter: parent.horizontalCenter;
            anchors.bottom: parent.bottom;
            anchors.bottomMargin: 5;
            font.pixelSize: TPixelSizePreset.PH7
            text: "Version: " + T2D.version();
            color: "#909399"
        }

        Behavior on x {
            NumberAnimation {
                duration: 100
            }
        }
    }


}

